<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const p = new Promise((resolve, reject) => {
      setTimeout(function () {
        reject('出错啦');
      }, 1000);
    })

    p.catch(function (reason) {   // catch 方法，用来捕获错误，和 then 方法的2个形参的顺序相反
      console.warn(reason);
    })

  </script>
</body>

</html>